package com.lgd.btw.demo.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lgd.btw.demo.mapper.StudentMapper;
import com.lgd.btw.demo.mapper.UserMapper;
import com.lgd.btw.demo.pojo.Student;
import com.lgd.btw.demo.pojo.User;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.sql.Wrapper;
import java.util.ArrayList;
import java.util.List;

@Service
public class UserService {
    @Resource
    private UserMapper userMapper;
    @Resource
    private StudentMapper studentMapper;

    public User selectById(int id){
        return userMapper.selectById(id);
    };

    public List<User> getByUsername(String username) {
        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
        Object username1 = queryWrapper.eq("username", username);
        List<User> list = userMapper.selectList(queryWrapper);
        return list;
    }

    public int delete(List<Integer> list) {
        return userMapper.deleteBatchIds(list);
    }

    public int update(User user){
        return userMapper.updateById(user);
    }

    public int insert(User user) {
        return  userMapper.insert(user);
    }

    public List<Student> selectSD() {
        return studentMapper.selectSD();
    }
}
